﻿using Customer.Domain;
using Customer.Infrstructre.CusContactManager;
using Customer.Read.API.Applcation.Command.CusContactCommand;
using MediatR;

namespace Customer.Read.API.Applcation.CommandHandler.CusContactCommandHandler
{
    /// <summary>
    /// 显示客户联系人信息
    /// </summary>
    public class SelectCusContactCommandHandler : IRequestHandler<SelectCusContactCommand, List<CusContact>>
    {
        private readonly ICusContactRepository _cusContactRep;

        public SelectCusContactCommandHandler(ICusContactRepository cusContactRep)
        {
            this._cusContactRep = cusContactRep;
        }

        public async Task<List<CusContact>> Handle(SelectCusContactCommand request, CancellationToken cancellationToken)
        {
            return (await _cusContactRep.GetAllAsync()).Where(t => t.IsDel == false).ToList();
        }
    }
}
